package cn.hbu.zlfw.exception;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
/**
 * 
 *@ClassName:ZLFWExceptionResolver.java
 *@Description:  自定义全局异常
 *@Author:lxt<839376636@qq.com>
 *@Date:2017年10月9日下午9:11:44
 *@Version:1.1.0
 */
@Component 
public class ZLFWExceptionResolver implements HandlerExceptionResolver{

	public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
			Exception ex) {
		ex.printStackTrace();
		try {
			request.getRequestDispatcher("/error/error.jsp").forward(request, response);
			System.out.println("访问错误");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return new ModelAndView();
	}

}
